#ifndef __GLF_JNI_UTIL_H_INCLUDED__
#define __GLF_JNI_UTIL_H_INCLUDED__

#include <jni.h>

namespace glf {

class ScopeStringChars
{
public:

	ScopeStringChars(JNIEnv* env, jstring str): mEnv(env), mString(str), mChars(env->GetStringUTFChars(str, JNI_FALSE)) {
	}

	~ScopeStringChars() {
		mEnv->ReleaseStringUTFChars(mString, mChars);
	}

	const char* get() {
		return mChars;
	}

private:

	JNIEnv* mEnv;
	jstring mString;
	const char* mChars;
};

} // end namespace glf

#endif
